package com.example.controller;

import com.example.service.OllamaStreamingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class OllamaStreamingController {

    private final OllamaStreamingService streamingService;

    @Autowired
    public OllamaStreamingController(OllamaStreamingService streamingService) {
        this.streamingService = streamingService;
    }

    @GetMapping(value = "/stream", produces = "text/event-stream")
    public Flux<String> stream(@RequestParam String message) {
        return streamingService.streamChat(message);
    }
}
